Skip to content

Support E2B_SANDBOX_URL env var for Jupyter requests#310

Merged
mishushakov merged 4 commits into
mainfrom
add-e2b-sandbox-url-env-var
Jul 23, 2026
Merged

Support E2B_SANDBOX_URL env var for Jupyter requests#310
mishushakov merged 4 commits into
mainfrom
add-e2b-sandbox-url-env-var

Conversation

@mishushakov

Copy link
Copy Markdown
Member

Adds support for the E2B_SANDBOX_URL environment variable and the sandboxUrl/sandbox_url option in both the JS and Python code-interpreter SDKs, matching the base E2B SDK. The Jupyter URL now resolves through getSandboxDirectUrl() in JS and an equivalent check in Python (the Python base helper hardcodes the envd port, so the property checks the config's sandbox URL directly), falling back to the existing direct-host behavior when no override is set. All Jupyter requests now also send E2b-Sandbox-Id and E2b-Sandbox-Port headers — the same headers the base SDK sends for envd traffic — so a gateway or proxy behind a fixed sandbox URL can route them to the right sandbox and port. Includes offline unit tests for default, option, and env-var URL resolution in both SDKs, plus a minor changeset for both packages.

🤖 Generated with Claude Code

…quests

Resolve the Jupyter server URL through the sandbox URL override
(sandboxUrl/sandbox_url option or E2B_SANDBOX_URL environment variable),
matching the base E2B SDK, and send E2b-Sandbox-Id and E2b-Sandbox-Port
headers on Jupyter requests so a gateway or proxy can route them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Custom sandbox URL routing changes how all Jupyter traffic is reached; the sync Python token omission can break authenticated context management for existing users.

Overview
In sync Python, create_code_context, remove_code_context, list_code_contexts, and restart_code_context no longer attach X-Access-Token from _envd_access_token; the diff removed those blocks when adding the routing headers.

Reviewed by Cursor Bugbot for commit fee50df. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread js/src/sandbox.ts
Comment thread python/e2b_code_interpreter/code_interpreter_async.py
mishushakov and others added 2 commits July 17, 2026 15:19
…Token on context requests

Strip trailing slashes when the Jupyter URL comes from the sandbox URL
override so path concatenation can't produce double slashes, and send
X-Access-Token on the context-CRUD requests in the JS SDK and Python
AsyncSandbox, matching run_code and the Python sync Sandbox.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Callers are expected to pass a well-formed sandbox URL, matching the
base SDK, which also returns the override verbatim.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread python/e2b_code_interpreter/code_interpreter_async.py
The Jupyter server only reads X-Access-Token on /execute, where it
forwards the token to envd to fetch the sandbox's global env vars for
the execution. The context endpoints never read it, so drop the header
there — including from the sync Python SDK, which had been sending it
on all requests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fee50df. Configure here.

Comment thread python/e2b_code_interpreter/code_interpreter_sync.py
@mishushakov
mishushakov merged commit eb70a98 into main Jul 23, 2026
16 checks passed
@mishushakov
mishushakov deleted the add-e2b-sandbox-url-env-var branch July 23, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants